#ifndef LISTS_H
#define LISTS_H


#include <stdio.h>
#include <stdlib.h>

/*  
    This cannot work alone. 
    The structure El should be defined in advance !!! 
    
    EL cannot be a pointer.
*/

#include "el.h"
						
struct lnode{						
  El el;
  struct lnode *prev;
  struct lnode *next;						
};							

/** We cannot use this if we destruct the list */
#define FORALLIN(nodeptr,list)\
for(nodeptr=list;nodeptr!=NULL;nodeptr=nodeptr->next)
#define FORALLINBACK(nodeptr,list)\
for(nodeptr=list;nodeptr!=NULL;nodeptr=nodeptr->prev)


typedef struct lnode *List;				

extern List
list_make(El);

extern List
list_insert(El a, List i,List s);
	
extern List							
list_append_element(El, List);			

extern List							
list_prepend_element(El, List);
					
extern List						
list_add_element(El, List);	

extern int						
list_belongs(El e, List l, int (* eq)(El*,El *));	

extern struct lnode *
list_find(El a, List l, int (*eq)(El *,El *));

extern List							
list_concatenate(List, List);				
				
extern int 							
list_free(List);						
							
extern List 							
list_copy(List);						

extern List 							
list_copy_reverted(List);						
								
extern List
list_delete_element(List, List);

extern int
list_is_node(struct lnode * , List );

extern List
list_filter(List, int (*)(El) );

extern List
list_beginning_of(List);

extern int 
list_length(List l);


#endif /*  LISTS_H */
